home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / System / SYMBOL / Symbol Generators / Loops / symbol-divide < prev   
Lisp/Scheme  |  1998-10-23  |  2KB  |  49 lines

  1. symbol-divide operators how base symbol/vector  
  2.  
  3. This function divides a symbol or vector pattern into shorter chunks. Normally, the division is performed in equal basis, that is, to divide the whole pattern in equal chucks. There still exists a couple of extra controls making it possible to define both a chuck length pattern and a pattern that adds (or subtracts) offset on the starting division position. With the aid of flatten the operation is a relative to the gen-loop, but uses an algorithmic picking scheme.
  4.  
  5. Equal lengths
  6.  
  7. (symbol-divide 2 nil nil '(a b c d e f g))
  8. --> ((a b) (c d) (e f) (g))
  9.  
  10. Length pattern
  11.  
  12. (symbol-divide '(2 3) nil nil '(a b c d e f g))
  13. --> ((a b) (c d e) (f g))
  14.  
  15. Fixed length and offset pattern
  16.  
  17. (symbol-divide '(2 (-1 -2)) nil nil '(a b c d e f g) )
  18. --> ((a b) (b c) (b c) (c d) (c d) (d e) (d e) (e f) (e f) 
  19. (f g) (f g) (g) (g))
  20.  
  21. Length and offset patterns
  22.  
  23. (symbol-divide '((2 3) (-1 -2)) nil nil '(a b c d e f g))
  24. --> ((a b) (b c d) (c d) (d e f) (e f) (f g) (g))
  25.  
  26. Flattening output
  27.  
  28. (flatten (symbol-divide '((1 2 3) (-1 -2 1)) nil nil
  29.                         '(a b f g f e d c d e c b a)))
  30. --> (a a b a b f f f e f e d d d e d e c a a a)
  31.  
  32. Producing setq output
  33.  
  34. (symbol-divide 2 'setq 'mater '(a b c d e f g))
  35. -->
  36. (setq mater0 '(a b))
  37. (setq mater1 '(c d))
  38. (setq mater2 '(e f))
  39. (setq mater3 '(g))
  40.  
  41. Producing lib-symbol output
  42.  
  43. (symbol-divide 2 'lib-symbol 'synth '(a b c d e f g))
  44. -->
  45. (lib-symbol synth0 '(a b))
  46. (lib-symbol synth1 '(c d))
  47. (lib-symbol synth2 '(e f))
  48. (lib-symbol synth3 '(g))
  49.